package com.education.service.cms.controller.web;

import com.education.result.R;
import com.education.service.cms.entity.Ad;
import com.education.service.cms.service.AdService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 幻灯片数据的获取
 * Created by Lance on 2020/07/03 16:24
 */
@Api(tags = "广告推荐")
@RestController
//@RefreshScope   // 配置实时自动刷新配置文件
@RequestMapping("/web/cms/ad")
public class ApiAdController {

    @Autowired
    private AdService adService;

    @ApiOperation("根据推荐位id显示广告推荐")
    @GetMapping("list/{adTypeId}")
    public R listByAdTypeId(@ApiParam(value = "推荐位id", required = true) @PathVariable String adTypeId) {

        List<Ad> ads = adService.selectByAdTypeId(adTypeId);
        return R.ok().data("items", ads);
    }
}
